home *** CD-ROM | disk | FTP | other *** search
- Path: news.eden.com!usenet
- From: "Shane M. Sadler" <nexus@eden.com>
- Newsgroups: comp.lang.c
- Subject: Re: kbhit and getche loop
- Date: Sat, 03 Feb 1996 23:38:41 -0600
- Organization: Eden Matrix
- Message-ID: <31144661.1419@eden.com>
- References: <4f119f$7e7@jupiter.planet.net>
- NNTP-Posting-Host: net-1-110.austin.eden.com
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0b5 (Win95; I)
-
- Chris Kemp wrote:
- >
- > I have the following code which I want to take characters from the stdin, and
- > append them onto a commandstring. [snip]
-
- > I think my problem is in processing the ch character, or perhaps comparing it to
- > '/n'.
- > If anyone has some thoughts about hot to do this, I'd sure would like a good
- > suggestion.
- > [snip]
-
- > int ch;
- > char *charget;
- > ch=getche();
- > *charget=ch;
- > strcat(commandstring,charget);
- >
- > if (ch=='/n') {
- > parse(commandstring, delimiter); //separate it into tokens
- > store in parsedarray[MAXWORDS][SIZE]
- > processcommandincommandstring();
- > }
- > } while (0 EQ 0); //infinite loop
-
- What sort of error are you getting? One problem just might be that you're
- checking for '/n'. Are you trying to check for '\n' perhaps? I can't tell
- from your snippet: is there a reason why you don't want to just read in whole
- strings (using gets() or whatever you want) and concatenate the whole mess
- into commandstring using sprintf() (okay, or strcat())instead of reading it
- in character-by-character?
-
- Cheers,
- Shane
-